// pages/peTest/exercise/exercise.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    curTab: 0, // tab切换
    homeTest: []

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.getHomeTestData()
  },
  bindChange: function(e) {
    this.setData({
      curTab: e.detail.current
    })
  },
  // 点击tab切换
  swichNav: function(e) {
    if (this.data.curTab === e.target.dataset.current) {
      return false
    } else {
      this.setData({
        curTab: e.target.dataset.current
      })
    }
  },
  // 查看标准
  lookStandards() {
    wx.navigateTo({
      url: "/pages/peTest/peTest/peTest"
    })
  },
  // 查看历史
  checkHistory() {
    wx.navigateTo({
      url: "/pages/peTest/homework/homework"
    })
  },
  // 请求测试列表数据
  getHomeTestData() {
    // app.api.ajaxSubmit("", {
    //   studentName: this.data.studentName,
    //   studentNumber: this.data.studentNumber
    // }).then(res => {
    //   if (res.data.error == 10000 && res.data.data) {
    // let homeTest = res.data.data.student;
    let homeTest = [{
        physicalTestType: 2,
        physicalScore: 8500
      },
      {
        physicalTestType: 3,
        physicalScore: 8500
      },
      {
        physicalTestType: 6,
        physicalScore: 8500
      },
      {
        physicalTestType: 7,
        physicalScore: 8500
      },
    ]
    let myhometest = [];
    homeTest.forEach(item => {
      myhometest.push({
        physicalTestType: item.physicalTestType,
        physicalScore: item.physicalScore,
        physicalTestName: app.utils.formatPhysicalTest(item.physicalTestType)
      })
    })
    this.setData({
      homeTest: myhometest
    })

    //   } else {
    //     wx.showToast({
    //       title: res.data.message,
    //       duration: 2000,
    //       icon: "none",
    //       mask: true
    //     })
    //   }
    // }).catch(err => {
    //   wx.showToast({
    //     title: "服务器开小差",
    //     duration: 2000,
    //     icon: "none",
    //     mask: true
    //   })
    // })
  }
})